//
//  HKShareWebViewControllerManager.m
//  HKTimeKitApp
//
//  Created by huzhaoke1 on 2023/8/11.
//

#import "HKShareWebViewControllerManager.h"
#import "HKWebViewController.h"
#import "HKRequestDefine.h"
#import <BlocksKit/BlocksKit.h>

@interface HKShareWebViewControllerManager ()

@property (nonatomic, strong) NSDictionary<NSString *, HKWebViewContainer *> *contanerDic;

@end

@implementation HKShareWebViewControllerManager

+ (instancetype)sharedInstance {
    static HKShareWebViewControllerManager *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [HKShareWebViewControllerManager new];
    });
    return instance;
}

- (instancetype)init {
    if (self = [super init]) {
        NSMutableDictionary<NSString *, HKWebViewContainer *> *contanerDics = [NSMutableDictionary dictionary];
        [[self containerUrls] bk_each:^(id obj) {
            HKWebViewContainer *container = [HKWebViewContainer new];
            [container loadingRequestWithUrl:obj];
            contanerDics[obj] = container;
        }];
        self.contanerDic = contanerDics.copy;
    }
    return self;
}

- (HKWebViewContainer *)webViewContainerWithUrl:(NSString *)url {
    if (url.length == 0) return nil;
    return self.contanerDic[url];
}
- (NSArray<NSString *> *)containerUrls {
    return @[HKCreatescheduleUrl,
             HKEmotionhomeUrl,
             HKExperienceUrl,
             HKCreateGoalUrl,
             HKQuestionhomeUrl,
             HKMessagefortesterUrl];
}

@end
